package com.service.xsxt;

import com.dao.xsxt.StudentMapper;
import com.entity.common.ApiResult;
import com.entity.xsxt.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by System on 2019/04/15 08:55:25.
 */
@Service
public class StudentService {

    @Autowired
    private StudentMapper studentMapper;

    public List<Student> getPageList(Student student){
        return studentMapper.getPageList(student);
    }

    public ApiResult addStudent(Student student) {
        int num = studentMapper.insertSelective(student);
        return  new ApiResult(num);
    }

    public ApiResult getStudentById(Long id) {
        Student student = studentMapper.selectByPrimaryKey(id);
        return new ApiResult(true,"获取数据成功！",student);
    }

    public ApiResult editStudent(Student student) {
        int num = studentMapper.updateByPrimaryKeySelective(student);
        return  new ApiResult(num);
    }

    public ApiResult deleteStudent(Long id) {
        int num = studentMapper.deleteByPrimaryKey(id);
        return  new ApiResult(num);
    }

    public Student findStudentByStuno(Student student) {
        return studentMapper.findStudentByStuno(student);
    }
}
